package com.controller;

import com.entity.CatUser;
import com.service.CatUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class CatUserController {

    @Autowired
    CatUserService catUserService;

    @RequestMapping("/CatRegister")
    public String AddUser(@RequestBody CatUser catUser){
        int i = catUserService.AddUser(catUser);
        return i > 0 ? "success" : "error";
    }

    @RequestMapping("/CatUserAdd")
    public String AddUserMsg(@RequestBody CatUser catUser){
        int i = catUserService.AddUserMsg(catUser);
        return i > 0 ? "success" : "error";
    }

    @RequestMapping("/ResetPassword")
    public String ResetPassword(String username){
        int i = catUserService.ResetPassword(username);
        return i > 0 ? "success" : "error";
    }

    @RequestMapping("/CatUserDel")
    public String UserDelete(String username){
       int i = catUserService.UserDelete(username);
        return i > 0 ? "success" : "error";
    }

    @RequestMapping("/CatUserMsg")
    public List<CatUser> UserMsg(){
        List a = catUserService.UserMsg();
        return a;
    }
}
